<?php

namespace App\Helpers\Api;


trait UnionPayTrait
{
    function initUnionPayConfig(){
        $gateway    = \Omnipay\Omnipay::create('UnionPay_Express'); //银联全产品网关（PC，APP，WAP支付）
        $gateway->setMerId('777290058180023');  //商户号
//        $gateway->setCertId('68759663125');
//        $gateway->setPrivateKey(base_path().'/pem/UnionPay5.1/private_key.pem'); // path or content
        $gateway->setCertPath(base_path().'/pem/UnionPay/700000000000001_acp.pfx'); // 商户私钥证书
        $gateway->setCertDir(base_path().'/pem/UnionPay');  //测试环境银联公钥证书
        $gateway->setCertPassword('000000');  // 密码
        $gateway->setReturnUrl(route('api.pay.notify')); // 支付后同步通知页面地址
        $gateway->setNotifyUrl(route('api.pay.notify'));
        return $gateway;
    }

    public function finishUnionPayConfig() {
        $gateway    = \Omnipay\Omnipay::create('UnionPay_Express'); //银联全产品网关（PC，APP，WAP支付）
        $gateway->setMerId('777290058180023');  //商户号
        $gateway->setPublicKey(base_path().'/pem/UnionPay/verify_sign_acp.cer'); // path or content

        return $gateway;
    }
}
